home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_03
/
kamradt
/
inline.h
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-07
|
776b
|
44 lines
class Base {
public:
virtual void print()
{ printf("Base"); }
};
class Derived1 : public Base {
public:
virtual void print()
{
// Base::print() can be inlined
Base::print();
printf("Derived1");
}
};
class Derived2 : public Base {
public:
virtual void print()
{
// Base::print() can be inlined
Base::print();
printf("Derived2");
}
};
void function(Base *bp)
{
// Doesn't know whether
// to call Derived1::print()
// or Derived2::print(),
// won't inline:
bp->print();
// Forced to call Base::print(),
// can inline:
bp->Base::print();
Derived1 d1o;
// Forced to call
// Derived1::print(), can
// inline:
d1o.print();
}